/*******************************************

Teste da diretiva parbegin

*******************************************/#include <cpar.h>
static CPARContext *pGlobalContext;
typedef struct CPARGlobalStackData{
long __CPAR_VERSION__;
 int y;
 int x;
}CPARGlobalStackData;
static CPARGlobalStackData *pGlobalStack;

void CPARTask_tarefa1_block2(CPARContext *pContext);
void CPARTask_tarefa1_block1(CPARContext *pContext);

#include <stdio.h>

;
;
void CPARTask_tarefa1(CPARContext *pContext);

void CPARTask_tarefa1_block2(CPARContext *pContext){
pGlobalStack->y=2;}
void CPARTask_tarefa1_block1(CPARContext *pContext){
pGlobalStack->x=1;}void CPARTask_tarefa1(CPARContext *pContext)
{ 
   CPARContextRunBlocks(pContext,2,CPARTask_tarefa1_block1,CPARTask_tarefa1_block2);
      
   
      
   
}

int main(int argc, char **argv)
{
   CPARInit();if( CPARContextCreate( NULL, &pGlobalContext, sizeof(CPARGlobalStackData) )){  CPAR_ERROR("Falha ao alocar contexto global");  return CPAR_E_NO_MEMORY;}pGlobalStack = (CPARGlobalStackData*) CPARContextStackGet(pGlobalContext);if( CPARContextWorkPoolCreate( pGlobalContext, 2)){CPAR_ERROR("Falha ao alocar work pool");return -1;}CPAR_DEFINE_VERSION;;
   CPARContextTaskDispatch(pGlobalContext,2,CPARTask_tarefa1,0);
   CPARContextTaskWaitAll(pGlobalContext);
   printf("x=%d  y=%d \n",pGlobalStack->x,pGlobalStack->y);
   fflush(stdout);
return 0;} 
